home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doBrowserHelp.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.6 KB  |  326 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-1998 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //------------------------
  34. //
  35. //  Alias|Wavefront Script File
  36. //  MODIFY THIS AT YOUR OWN RISK
  37. //
  38. //  Creation Date:  July 15 1997
  39. //  Author:         cdg
  40. //
  41.  
  42.  
  43. global proc findBrowserWin() {
  44. //
  45. //  Description:
  46. //        Find a browser window of the correct type.  
  47. //
  48. //
  49.  
  50.     global string $gHelpBrowserWinID = "";
  51.     global int    $gUseHelpBrowserWin = false;
  52.  
  53.     string $cmdStr;
  54.     string $resStr;
  55.     string $resStrs[];
  56.     int $nArr;
  57.     int $notDone = true;
  58.     int $i;
  59.  
  60.     //
  61.     //  Generate a list of browser windows.
  62.     //
  63.     waitCursor -state on;
  64.  
  65.     $cmdStr = "xwininfo -root -tree | grep 'Netscape:'";
  66.     $resStr = system($cmdStr);
  67.     tokenize $resStr "\n" $resStrs;
  68.  
  69.     if (1 == size($resStrs) && "" == $resStrs[0]) {
  70.         //
  71.         //  Netscape window isn't up yet. Check again.
  72.         //
  73.         for ($i = 0; $i < 5; $i++) {
  74.             $resStr = system($cmdStr);
  75.             tokenize $resStr "\n" $resStrs;
  76.             
  77.             if ("" != $resStrs[0]) {
  78.                 $gUseHelpBrowserWin = true;
  79.                 break;
  80.             }
  81.         }
  82.     } else {
  83.         $gUseHelpBrowserWin = true;
  84.     }
  85.  
  86.     //
  87.     //  Test the windows to make sure that we have a browser window,
  88.     //  not a news, or mail window.
  89.     //
  90.     //  If we are looking for an existing window start at the beginning
  91.     //  of the list.  If we are looking for a new window start at the 
  92.     //  end of the list.
  93.     //
  94.     $nArr = size ($resStrs);
  95.     $i = $gUseHelpBrowserWin ? 0 : $nArr - 1;
  96.     while ($notDone) {
  97.         if ($i >= 0 && $i < $nArr) {
  98.             //
  99.             //  Extract X window id
  100.             //
  101.             if ($gUseHelpBrowserWin) {
  102.                 $gHelpBrowserWinID = match("0x[0-9a-f]*", $resStrs[$i++]);
  103.             } else {
  104.                 $gHelpBrowserWinID = match("0x[0-9a-f]*", $resStrs[$i--]);
  105.             }
  106.  
  107.             if ($gHelpBrowserWinID != "") {
  108.                 //
  109.                 //  Test for a browser window.
  110.                 //
  111.                 $resStr = system(("xprop -id "+ $gHelpBrowserWinID + 
  112.                                   " | grep WM_CLASS | grep Navigator"));
  113.  
  114.                 if ("" != $resStr) {
  115.                     $notDone = false;
  116.                 }
  117.             }
  118.         } else {
  119.             $notDone = false;
  120.         }
  121.     }
  122.  
  123.     waitCursor -state off;
  124. }
  125.  
  126. global proc doBrowserHelp(string $args[]) {
  127. //
  128. //  Description:
  129. //        Launches a web browser for viewing help. The args array
  130. //        provides a way of giving a hierarchical specification of
  131. //        the help required. If no args are provided the top of the 
  132. //        help tree will be used.
  133. //
  134. //  Arguments:
  135. //        args[0] - Top Level eg. Commands, Tutorial, Animation, etc
  136. //        args[1] - First sub heading eg. "ambientLight" for cmds
  137. //        args[...] - as many more levels as needed to specify help required.
  138. //
  139. //  Currently Defined Top Level args:
  140. //        "Top"            - Top of the help hierarchy.  This is the default if no args 
  141. //                          are supplied.
  142. //        "Commands"        - Documentation on individual commands.
  143. //        "UserRelative"    - The following args are a path relative to the help root
  144. //                          provided by the user.  The will be appended to the root URL.
  145. //        "UserAbsolute"    - The following args provide a complete URL.  They will not
  146. //                          be appended to the root URL.
  147. //
  148. //
  149.  
  150.     global string $gHelpBrowserWinID;
  151.     global int    $gUseHelpBrowserWin;
  152.     global int    $gRaiseHelpBrowserWin;
  153.  
  154.     int    $i;
  155.     int    $nArgs = size($args);
  156.     string $cmdStr;
  157.     string $browserCmd = "netscape "; 
  158.     string $resStr;
  159.     string $resStrs[];
  160.     string $URL;
  161.     string $helpRoot = getenv("MAYA_HELP_URL");
  162.  
  163.     int $len = `size($helpRoot)`;
  164.     if (0 == $len) {
  165.         // The environment variable wasn't set so try again
  166.         $helpRoot = getenv("MAYA_LOCATION");
  167.         $helpRoot += "/docs/en_US/html/";
  168.     } else {
  169.         // Make sure the string ends in a slash
  170.         if (`substring $helpRoot $len $len` != "/") {
  171.             $helpRoot += "/";
  172.         }
  173.     }
  174.  
  175.     //
  176.     //  Build appropriate URL
  177.     //
  178.     if ($nArgs == 0) {
  179.             $URL = $helpRoot;
  180.     } else if ("Top" == $args[0]) {
  181.             $URL = ($helpRoot + "MasterIndex.html");
  182.     } else if ("Commands" == $args[0]) {
  183.         if ($nArgs == 1 ) {
  184.             $URL = ($helpRoot + "Commands/index.html");
  185.         } else {
  186.             $URL = ($helpRoot + "Commands/" + $args[1]);
  187.         }
  188.     } else if ("UserRelative" == $args[0]) {
  189.         if ($nArgs == 1 ) {
  190.             //
  191.             //  No further info provided, just go to the root.
  192.             //
  193.             $URL = $helpRoot;
  194.         } else {
  195.             $URL = $helpRoot;
  196.             for ($i = 1; $i < $nArgs; $i++) {
  197.                 $URL += $args[$i];
  198.                 if ($i < $nArgs-1) {
  199.                     $URL += "/";
  200.                 }
  201.             }
  202.         }
  203.     } else if ("UserAbsolute" == $args[0]) {
  204.         if ($nArgs == 1 ) {
  205.             //
  206.             //  No further info provided, just go to the root.
  207.             //
  208.             $URL = $helpRoot;
  209.         } else {
  210.             $URL = "";
  211.             for ($i = 1; $i < $nArgs; $i++) {
  212.                 $URL += $args[$i];
  213.                 if ($i < $nArgs-1) {
  214.                     $URL += "/";
  215.                 }
  216.             }
  217.         }
  218.     } else {
  219.             $URL = $helpRoot;
  220.     }
  221.  
  222.  
  223.     //NT we want to execute the URL and let windows
  224.     //locate the default browser for us.
  225.     if (`about -nt`) {
  226.         string $upperURL = toupper($URL);
  227.         if (!gmatch($upperURL, "HTTP:*")) {
  228.             $URL = unconvert($URL);         // Only convert if using the file system.
  229.         }
  230.  
  231.         if( false && `optionVar -q helpInMainWindow` ) {
  232.             htmlWidget -edit -url $URL helpPanel1HelpWidget;
  233.         }
  234.         else {
  235.             $URL = "load " + $URL;  // load is keyword for our custom popen to use ShellExecute
  236.             waitCursor -state on;
  237.             $browserCmd = system($URL);  // NT only
  238.             waitCursor -state off;
  239.         }
  240.     }
  241.     else 
  242.     {
  243.  
  244.     //
  245.     //  Build netscape cmd string
  246.     //
  247.     if ("" != system("ps -u `whoami` | grep netscape")) {   // GG: not executed on NT
  248.         //
  249.         //  Running copy of browser found.
  250.         //
  251.         if ("" != $gHelpBrowserWinID) {
  252.             //
  253.             //  Already have a X window id.  Check that it is still valid.
  254.             //
  255.             $resStr = system(("xwininfo -id "+$gHelpBrowserWinID));  // GG: not executed on NT
  256.             if ("" == $resStr) {
  257.                 //
  258.                 //  X id is no good.  Window has been closed.
  259.                 //
  260.                 $gHelpBrowserWinID = "";
  261.             }
  262.         }
  263.  
  264.         if ($gUseHelpBrowserWin && $gHelpBrowserWinID == "") {
  265.             //
  266.             //  Find an existing browser window.
  267.             //
  268.             waitCursor -state on;
  269.             findBrowserWin;
  270.             waitCursor -state off;
  271.         }
  272.  
  273.  
  274.         if ("" != $gHelpBrowserWinID) {
  275.             //
  276.             //  Specify which window we want to use.
  277.             //
  278.             $browserCmd += ("-id " + $gHelpBrowserWinID + " ");
  279.         }
  280.  
  281.         //
  282.         //  Add 'raise' window option.
  283.         //
  284.         if ($gRaiseHelpBrowserWin && "" != $gHelpBrowserWinID) {
  285.             $browserCmd += "-raise ";
  286.         } else {
  287.             $browserCmd += "-noraise ";
  288.         }
  289.  
  290.         //
  291.         //  Specify the URL, and whether we want a new window.
  292.         //
  293.         $browserCmd += ("-remote 'openURL(" + $URL);
  294.         if (!$gUseHelpBrowserWin && "" == $gHelpBrowserWinID) {
  295.             $browserCmd += ",new-window)'";
  296.         } else {
  297.             $browserCmd += ")'&";
  298.         }
  299.  
  300.     } else {
  301.         //
  302.         //  Open a new version of the browser.  Need to use a shell script
  303.         //  so that it won't block.
  304.         //
  305.         $gHelpBrowserWinID = "";
  306.         $browserCmd = ("launchNetscapeHelp "+ $URL);
  307.     }
  308.  
  309.     //
  310.     //  Run the shell cmd to start or communicate with the browser..
  311.     //
  312.     waitCursor -state on;
  313.     system($browserCmd);      // GG: not executed on NT
  314.     waitCursor -state off;
  315.  
  316.     if ("" == $gHelpBrowserWinID) {
  317.         //
  318.         //  Remember the window id for next time.
  319.         //
  320.         findBrowserWin;
  321.     }
  322.  
  323.     }//NT end exist
  324.  
  325. }
  326.